import 'dart:async';
import 'package:demo/event/event_setting.dart';
import 'package:demo/views/base/base_controller.dart';
import 'package:demo/tools/tools_enum.dart';
import 'package:demo/tools/tools_storage.dart';

class MinePrivacyController extends BaseController {
  LocalUser localUser = ToolsStorage().local();

  // 修改隐私
  Future<void> editPrivacyNo(String privacyNo) async {
    // 修改
    localUser.privacyNo = privacyNo;
    update();
    // 通知
    EventSetting().handle(
      SettingModel(
        SettingType.mine,
        label: 'privacyNo',
        value: privacyNo,
      ),
    );
  }

  // 修改隐私
  Future<void> editPrivacyPhone(String privacyPhone) async {
    // 修改
    localUser.privacyPhone = privacyPhone;
    update();
    // 通知
    EventSetting().handle(
      SettingModel(
        SettingType.mine,
        label: 'privacyPhone',
        value: privacyPhone,
      ),
    );
  }

  // 修改隐私
  Future<void> editPrivacyScan(String privacyScan) async {
    // 修改
    localUser.privacyScan = privacyScan;
    update();
    // 通知
    EventSetting().handle(
      SettingModel(
        SettingType.mine,
        label: 'privacyScan',
        value: privacyScan,
      ),
    );
  }

  // 修改隐私
  Future<void> editPrivacyCard(String privacyCard) async {
    // 修改
    localUser.privacyCard = privacyCard;
    update();
    // 通知
    EventSetting().handle(
      SettingModel(
        SettingType.mine,
        label: 'privacyCard',
        value: privacyCard,
      ),
    );
  }

  // 修改隐私
  Future<void> editPrivacyGroup(String privacyGroup) async {
    // 修改
    localUser.privacyGroup = privacyGroup;
    update();
    // 通知
    EventSetting().handle(
      SettingModel(
        SettingType.mine,
        label: 'privacyGroup',
        value: privacyGroup,
      ),
    );
  }
}
